home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12955 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.4 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Coding Standards
  5. Date: Fri, 22 Mar 1996 13:17:32 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <3152EEBC.3F9F@datalytics.com>
  8. References: <4hj8ek$elu@sam.inforamp.net> <4hktar$5o2@galaxy.ucr.edu> <4hmqol$97j@abacus.abasoft.co.uk> <4hsg8r$pmm@sam.inforamp.net> <4i9o6j$p4l@daisy.pgh.wec.com> <4idskb$pc1@sam.inforamp.net> <314EBD08.43BC@virtus.com> <4io2i7$n9v@sam.inforamp.net>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Randy Charles Morin wrote:
  16. > In article <314EBD08.43BC@virtus.com>,
  17. >    "Richard F. Albury" <richard.albury@virtus.com> wrote:
  18. > >// is the standard C++ comment, so I'm not sure I understand your objection.
  19. > What I meant was that the /* */ has been the only standard comment for years.
  20. >  The // comment style is a new proposed standard.
  21.  
  22. It may only be formalized in a standard in the future, but it 
  23. has been part of every C++ compiler since the beginning.  That 
  24. makes it a de facto standard.  This industry has many de facto 
  25. standards upon which we all rely daily.
  26.  
  27. > >>         -a class which can be instantiated with a "new" must have a copy
  28. > >> constructor, a destructor and an assignment operator definition.
  29. > >
  30. > >It's good discipline.  Read Scott Meyers' books for more info.
  31.  
  32. Perhaps it's good discipline, but a copy c'tor and assignment op 
  33. are useful only when you wish to grant that capability.  (To 
  34. deny it, you must declare them private and not implement them, 
  35. of course.)  What I want to know is why instantiating an object 
  36. on the heap requires them.
  37.  
  38. > Unfortunately, if we follow everybodies good discipline guidelines, we would
  39. > miss our October deadline by a few years.
  40. > >>         -optimize code only when you have a problem.
  41. > >>         Why not anticipate the problem?
  42. > >
  43. > >You rarely can.  Read Plauger's writings on style.  One of his sayings is
  44. > >"First make it right, then make it fast."  If performance is an issue, use a
  45. > >profiler.
  46. > You are right.  But the standard explicitly stated that no optimization could
  47. > be done until there was a problem.  I'd hate to see that problem in the field.
  48. >  I'd rather anticipate the problem, most likely by doing exactly what you
  49. > suggested.
  50. > >>         -access functions are to be inline.
  51. > >>         This is the biggest fallacy in programming today.  If you make your
  52. > >> accessors inline, then you have defeated the purpose of data hiding.  If
  53. > >> your data's type changes, then you still have to recompile every object
  54. > >> that accesses the member.
  55. > >
  56. > >Agreed.
  57.  
  58. Compilation firewalls are useful to prevent significant 
  59. recompilation and offer the ability to augment a simple function 
  60. later with more logic to retain the interface in light of an 
  61. implementation change.  However, performance is also an issue.  
  62. If all accessor functions are left as non-inline function calls, 
  63. then your code will bloat and perform worse.
  64.  
  65. The maturity of a class and its use must be considered when 
  66. deciding to inline an accessor.  If the class is well 
  67. established and is unlikely to change, inline accessors make 
  68. great sense.
  69.  
  70. > Thank you.  I have a hard time convincing anybody of this.
  71. > Agrivar
  72.  
  73. -- 
  74. Robert Stewart        | My opinions are usually my own.
  75. Datalytics, Inc.    | stew@datalytics.com
  76.